package com.yld.car.common;

import com.yld.car.market.R;

import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public class ViewUtils {
	public static void addPageView(Context paramContext,
			LinearLayout paramLinearLayout, int position, int size) {
		paramLinearLayout.removeAllViews();
		LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(
				dip2px(paramContext, 6.0F), dip2px(paramContext, 6.0F));
		localLayoutParams.setMargins(0, 0, dip2px(paramContext, 5.0F),
				dip2px(paramContext, 5.0F));

		for (int i = 0; i < size; i++) {

			TextView tv = new TextView(paramContext);
			tv.setLayoutParams(localLayoutParams);
			if (position == i) {
				tv.setBackgroundResource(R.drawable.shape_page_point_on);
			} else {
				tv.setBackgroundResource(R.drawable.shape_page_point);
			}
			paramLinearLayout.addView(tv);
		}

	}

	public static int dip2px(Context paramContext, float paramFloat) {
		return (int) (0.5F + paramFloat
				* paramContext.getResources().getDisplayMetrics().density);
	}
}
